/**
 * @Author: zzy
 * @Date: 2023-02-24 08:53:40
 * @LastEditTime: 2023-03-23 08:56:55
 * @LastEditors: cest cestrmail@163.com
 * @FilePath: /cmes-project-cli/src/utils/service/index.js
 * @Description: 编辑描述内容
 */


import { http } from './request'
import { noTokenhttp } from './requestWithOutToken'
export const useApi = () => {
  return {
    get: (url, params, config = {}) => http.get(url, { params, ...config }),
    post: (url, data = {}, config = {}) => http.post(url, data, config),
    delete: (url, data = {}, config = {}) => http.delete(url, data, config),
    upload: (url, config = {}) => http.upload(url, config),
    put: (url, data = {}, config = {}) => http.put(url, data, config)
  }
}

// eslint-disable-next-line camelcase
export const useApi_noToken = () => {
  return {
    get: (url, params, config = {}) => noTokenhttp.get(url, { params, ...config }),
    post: (url, data = {}, config = {}) => noTokenhttp.post(url, data, config),
    delete: (url, data = {}, config = {}) => noTokenhttp.delete(url, data, config),
    upload: (url, config = {}) => noTokenhttp.upload(url, config),
    put: (url, data = {}, config = {}) => noTokenhttp.put(url, data, config)
  }
}

const env = process.env
export const API_BASE_URL = env.VUE_APP_API_BASE_URL ?? `http://127.0.0.1:8212`
